package com.wei.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wei.client.VodClientFeign;
import com.wei.entity.Video;
import com.wei.service.VideoService;
import com.wei.mapper.VideoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author HASEE
 * @description 针对表【edu_video(课程视频)】的数据库操作Service实现
 * @createDate 2022-11-23 09:57:54
 */
@Service
public class VideoServiceImpl extends ServiceImpl<VideoMapper, Video>
        implements VideoService {

    @Autowired
    private VodClientFeign vodClientFeign;

    @Override
    public void deleteVideoById(String id) {

        //删除视频
        Video video = baseMapper.selectById(id);

        String videoSourceId = video.getVideoSourceId();

        if (StrUtil.isNotBlank(videoSourceId)) {
            vodClientFeign.removeVideo(videoSourceId);
        }

        //删除小节
        baseMapper.deleteById(id);
    }
}




